﻿using System.Globalization;
using Balloonerds.Algebra;

namespace RayTracer
{
    public class Circle : Plane
    {
        public double Radius { get; set; }

        public override Intersection GetIntersection(Ray ray)
        {
            var intersection = base.GetIntersection(ray);

            if (intersection != null)
            {
                var rp = intersection.Point - Origin;
                if (rp * rp > Radius * Radius)
                    intersection = null;
            }

            return intersection;
        }

        public override string ToString()
        {
            return string.Format(NumberFormatInfo.InvariantInfo, "Circle:N{0};O{1},R{2:0.000}", Normal, Origin, Radius);
        }
    }
}
